TestApp::Application.routes.draw do
  get "suppliers/login"

  get "suppliers/filters" 
  
  get "suppliers/login" => "suppliers#login", :as => "suppliers_login"
  get "suppliers/logout" => "suppliers#logout", :as => "suppliers_logout"
  post "suppliers/do_login"
  post "suppliers/add_filter"  
  match 'suppliers/update_car_brand_select/:id', :controller => 'suppliers', :action => 'update_car_brand_select'
  delete 'suppliers/filters/:id', :controller => 'suppliers', :action => 'destroy_filter'

  resources :suppliers

  resources :regions

  resources :requests
  
  resources :original_types

  resources :used_types

  resources :part_configurations

  resources :carts

  resources :cars

  get "admin" => "admin#index", :as => "admin"
  get "admin/login" => "admin#login", :as => "admin_login"
  get "admin/logout" => "admin#logout", :as => "admin_logout"
  get "admin/unapproved_requests" => "admin#unapproved_requests", :as => "admin_unapproved_requests"
  get "admin/approved_requests" => "admin#approved_requests", :as => "admin_approved_requests"
  get "admin/create_new_supplier" => "admin#create_new_supplier", :as => "admin_create_new_supplier"
  get "admin/new_admin"
  post "admin/create_new_admin"
  
  get "admin/autocomplete_part_name"
  
  post "admin/do_login"
  put "admin/update_request_part_configuration"
  put "admin/update_request"
  match "admin/edit_request/:id", :controller => 'admin', :action => 'edit_request', :as => "admin_edit_request"
  match "admin/delete_part_configuration/:id", :controller => 'admin', :action => 'delete_part_configuration', :as => "admin_delete_part_configuration"
  
  get "home" => "welcome#home", :as => "home"

  resources :users
  
  resources :sessions

  resources :cities

  resources :gearbox_types

  resources :engine_types

  resources :parts  

  resources :parts_groups

  resources :car_models

  resources :car_brands

  root :to => "welcome#show"
  
  get "log_out" => "sessions#destroy", :as => "log_out"
  get "log_in" => "sessions#new", :as => "log_in"
  get "sign_up" => "users#new", :as => "sign_up"

  get "welcome/show"
  get "welcome/autocomplete_part_name"
  get "welcome/autocomplete_city_name"
  post "welcome/show2"
  
  match 'welcome/update_car_brand_select/:id', :controller => 'welcome', :action => 'update_car_model_select'
  match 'cars/update_car_brand_select/:id', :controller => 'cars', :action => 'update_car_model_select'  

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
end
